<!-- 分成 -->
<template>
  <div class="qingwu">
    <div class="admin_main_block">
      <div class="admin_main_block_top">
        <div class="admin_main_block_left">
          <div>商品分成</div>
        </div>

        <div class="admin_main_block_right">
          <div>
            <el-button icon="el-icon-back" @click="$router.go(-1)">返回</el-button>
          </div>
        </div>
      </div>

      <div class="admin_form_main">
        <el-form label-width="100px" :disabled="isDisabled" ref="info" :model="info">
          <el-row>
            <h3 class="mt_50">会员销售佣金</h3>
            <el-col :span="12">
              <el-form-item label="直推奖励" prop="member_direct_reward" :rules="[{required:true,message:'请输入直推奖励',trigger: 'blur' }]">
                <el-input clearable type="number" placeholder="请输入分成百分比" v-model="info.member_direct_reward"><template slot="append">%</template></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="间推奖励" prop="member_indirect_reward" :rules="[{required:true,message:'请输入间推奖励',trigger: 'blur' }]">
                <el-input clearable type="number" placeholder="请输入分成百分比" v-model="info.member_indirect_reward"><template slot="append">%</template></el-input>
              </el-form-item>
            </el-col>
            <h3>顾问管理奖金</h3>
            <el-col :span="12">
              <el-form-item label="一级奖励" prop="consultants_first_reward" :rules="[{required:true,message:'请输入一级奖励',trigger: 'blur' }]">
                <el-input clearable type="number" placeholder="请输入分成百分比" v-model="info.consultants_first_reward"><template slot="append">%</template></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="二级奖励" prop="consultants_second_reward" :rules="[{required:true,message:'请输入二级奖励',trigger: 'blur' }]">
                <el-input clearable type="number" placeholder="请输入分成百分比" v-model="info.consultants_second_reward"><template slot="append">%</template></el-input>
              </el-form-item>
            </el-col>
            <h3>发起人管理奖金</h3>
            <el-col :span="12">
              <el-form-item label="二级奖励" prop="initiator_first_reward" :rules="[{required:true,message:'请输入一级奖励',trigger: 'blur' }]">
                <el-input clearable type="number" placeholder="请输入分成百分比" v-model="info.initiator_first_reward"><template slot="append">%</template></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="二级奖励" prop="initiator_second_reward" :rules="[{required:true,message:'请输入二级奖励',trigger: 'blur' }]">
                <el-input clearable type="number" placeholder="请输入分成百分比" v-model="info.initiator_second_reward"><template slot="append">%</template></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <el-button class="ml_100" type="primary" @click="submit">{{isDisabled?'编辑':'提交'}}</el-button>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      info: {
        id:1,
        member_direct_reward:'',      //会员直推奖励
        member_indirect_reward:'',    //会员间推奖励
        consultants_first_reward:'',  //顾问一级奖励
        consultants_second_reward:'', //顾问二级奖励
        initiator_first_reward:'',    //发起人一级奖励
        initiator_second_reward:'',   //发起人二级奖励
      },
      isDisabled: true,
    };
  },

  components: {},


  mounted() {
    this.get_goods_share();
  },

  methods: {
    submit() {
      this.isDisabled = !this.isDisabled;
      if (this.isDisabled) {
        this.edit_goods_share();
      }
    },
    get_goods_share() {
      this.$get(this.$api.editGoodsShare,this.info).then(res=>{
        this.info = Object.assign(this.info,res.data);
      })
    },
    edit_goods_share() {
      this.$post(this.$api.editGoodsShare,this.info).then(res=>{
        if(res.code == 200) {
          this.info = Object.assign(this.info,res.data);
          this.$message.success('修改成功');
        } else this.$message.error(res.msg);
      })
    }
  }
}

</script>
<style  scoped>
h3 {
  margin: 100px 0 20px 15px;
}
.el-input {
  width: 250px;
}
.mt_50 {
  margin-top: 50px;
}
.ml_100 {
  margin-left: 100px;
}
</style>